package com.example.agricultural_big_data.controller;


import com.alibaba.fastjson.JSONObject;
import com.example.agricultural_big_data.service.UserService;
import com.example.agricultural_big_data.util.LoginRequired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

/**
 * @author xiao yang
 * @Description: 用户注册
 * @date 2021/1/3113:22
 */
@RestController
@CrossOrigin
@RequestMapping("/user")
public class RegisterController {

    @Autowired
    UserService userservice;

    @LoginRequired
    @PostMapping("/register")
    public Object userRegister(@RequestBody JSONObject data) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        return userservice.register(data);
    }

    //注册管理员
    @LoginRequired
    @PostMapping("/registerMaster")
    public Object masterRegister(@RequestBody JSONObject data) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        return userservice.masterRegister(data);
    }
}
